1bec987de01261643dd8de3086969b6ac7603c83
[git-annex.git] /
1 [[!comment format=mdwn
2  username="joey"
3  subject="""Re: comment 6"""
4  date="2023-04-25T21:10:21Z"
5  content="""
6 Oh well spotted yarikoptic! I wish I had noticed your comment 2 hours ago,
7 but I was head down implementing --json-exceptions.
8
9 Ok, so `addurl` does `giveup "bad url"` and that does indeed result in json
10 output that lacks a `key` and has `"file":null` as well.
11
12 I'm sure that somewhere in `git-annex add`, it's possible for it to
13 `giveup` with an error too. Oh of course... a device file!
14
15         joey@darkstar:/home/joey/tmp/xxx>git-annex add --force-small null --json --json-error-messages
16         {"command":"add","error-messages":["git-annex: null is not a regular file"],"file":"null","input":["null"],"note":"adding content to git repository","success":false}
17         add: 1 failed
18
19 Other perhaps more likely cases where add can `giveup` include when it's unable
20 to remove all write perms due to an xattr, and probably some permissions
21 problems.
22
23 So, json consumers of add already have to deal with the `key` being missing.
24
25 Now, it might be that some git-annex commands don't `giveup`, so this would be
26 a new complication for consumers of their json. But so would adding a `giveup`
27 for any reason to a command, and I don't worry about that.
28
29 While I've implemented --json-exceptions, I don't like the complexity, so this new
30 information inclines me to rip it back out and instead handle the case of the
31 nonexistant file like:
32
33         {"command":"add","exception":"UNIQUEID","file":"foo","input":["foo"],"error-messages":["foo not found"],"success":false}
34 """]]